#ifndef DATA_PROVIDER_IMPL_HPP
#define DATA_PROVIDER_IMPL_HPP

#include "content/data_provider.hpp"

// class string_data_provider: public data_provider {
// public:
//     string_data_provider(std::string data): data_{std::move(data)} {}

//     data_category type() const override { return data_category::std_string; }

//     std::string get_std_string() override { return data_; }

//     void set_std_string(std::string v) override { data_ = std::move(v); }
// private:
//     std::string data_;
// };

#define BASIC_DATA_TYPE_IMPL(t,n,p,init,cat)\
class n##_data_provider: public data_provider { \
public: \
    n##_data_provider(const std::string &p) { \
        init; \
    } \
    data_category type() const override { return cat; } \
    t get_##n() override { return data_; } \
    void set_##n(t v) override { data_ = std::move(v); } \
private: \
    t data_; \
}

PI_API
bool parse_bool(const std::string &data);

BASIC_DATA_TYPE_IMPL(std::string, std_string, data, data_ = data, data_category::std_string);
BASIC_DATA_TYPE_IMPL(s64, s64, data, data_ = (s64)strtoll(data.c_str(), nullptr, 0), data_category::signed_integral);
BASIC_DATA_TYPE_IMPL(u64, u64, data, data_ = (u64)strtoull(data.c_str(), nullptr, 0), data_category::unsigned_integral);
BASIC_DATA_TYPE_IMPL(f64, f64, data, data_ = (f64)strtod(data.c_str(), nullptr), data_category::floating_point);
BASIC_DATA_TYPE_IMPL(bool, boolean, data, data_ = parse_bool(data), data_category::boolean);

#endif // DATA_PROVIDER_IMPL_HPP
